package com.doit.demo01;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Scanner;
@SuppressWarnings("all")

//键盘录入指定年份
//定义一个方法 获取当年2月份有多少天
public class test_calendar_test {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个年份:");
        int nian = sc.nextInt();
        System.out.println(nian + "年的2月份有" + day2(nian) + "天");
    }
    public static int day2(int nian)
    {
        Calendar c = Calendar.getInstance();
        c.set(nian,2,1);
        c.add(Calendar.DATE,-1);
        int i = c.get(Calendar.DATE);
        return i;

    }

    public static int dayy(int nian)
    {
        Calendar c = Calendar.getInstance();
        c.set(nian,2,1);//设定指定年的3.1日的时间
        c.add(Calendar.DATE,-1);//把日期减去一天,就是2月份的日期
        int i = c.get(Calendar.DATE);
        return i;


    }
    public static int day(int nian) throws ParseException {
        Calendar cc = Calendar.getInstance();
        cc.set(nian,2,1);
        cc.add(Calendar.DATE,-1);
        int i = cc.get(Calendar.DATE);
        return i;
    }


}
